import axios from 'axios'
import '../scss/index.scss'

const ul = document.querySelector('ul');


async function render() {
  const resp = await axios({
    method: 'GET',
    url: '/list'
  })

  const { data } = resp.data
  ul.innerHTML = data.map(v => `<li>${v}</li>`).join('')
}

render()

function tab({ title, con, i = 0 }) {
  [...title.children].forEach((item, index) => {
    item.addEventListener('click', () => {
      title.children[i].classList.remove('active')
      con.children[i].classList.remove('active')
      i = index
      title.children[i].classList.add('active')
      con.children[i].classList.add('active')
    })
  })

  title.children[i].click()
}

tab({
  title: document.querySelector('.title'),
  con: document.querySelector('.con'),
})



var map = new BMapGL.Map('container'); // 创建Map实例
map.centerAndZoom(new BMapGL.Point(116.404, 39.915), 12); // 初始化地图,设置中心点坐标和地图级别
map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放